﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GsnHelper;
using PetaPoco;
namespace ZhongheCms.Models
{
    public partial class GswViewMemberHelper
    {
        [ResultColumn]
        public GswTblMember MemberInfo { get; set; }
        [ResultColumn]
        public List<GswTblJobInfo> JobInfos { get; set; }
        public static Page<GswViewMemberHelper> GetHelpers(string sdate, string edate, string keywords, int cusid,int pageIndex)
        {
            var strSql = "select * from GswViewMemberHelper where ParentId=" + cusid;
            int flag = 0;
            if (!string.IsNullOrWhiteSpace(keywords))
            {
                strSql += " and  MemberName like '%" + keywords + "%' ";
                flag = 1;
            }
            if (InputValid.IsDate(sdate))
            {
                strSql += " and PubDate>='" + sdate + "'";
                flag = 1;
            }
            if (InputValid.IsDate(edate))
            {
                strSql += " and PubDate<='" + edate + "'";
                flag = 1;
            }
            if (flag == 0)
                strSql += " and HelpFlag=0";
            strSql += " order by id desc";
            var db = new ZhongheRepo();
            var qry = db.Page<GswViewMemberHelper>(pageIndex,20,strSql);
           
            return qry;
        }
    }
}